<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    /* 
      https://leetcode-cn.com/problems/intersection-of-two-linked-lists/
      思路：https://leetcode-cn.com/problems/intersection-of-two-linked-lists/solution/javascriptxiang-jiao-lian-biao-tu-jie-shuang-zhi-z/
    */
    function getIntersectionNode(headA, headB) {
      let pA = headA;
      let pB = headB;

      while (pA !== pB) {
        // 优先级：三目运算符 > 赋值运算符
        pA = pA ? pA.next : headB;
        pB = pB ? pB.next : headA;
      }

      return pA;
    }
  </script>
</body>
</html>